#include "../include/Item.hh"
#include "../include/ICharacter.hh"
#include <stdexcept>

namespace Game {
    // Default constructor
    Item::Item() 
        : name_("Default"), healthBoost_(0), 
          attackBoost_(0), defenseBoost_(0), 
          type_(HEALTH_POTION) {}

    // Parameterized constructor
    Item::Item(const std::string& name, int h, int a, int d, Type type)
        : name_(name), healthBoost_(h),
          attackBoost_(a), defenseBoost_(d),
          type_(type) {}

    // Copy constructor
    Item::Item(const Item& other)
        : name_(other.name_),
          healthBoost_(other.healthBoost_),
          attackBoost_(other.attackBoost_),
          defenseBoost_(other.defenseBoost_),
          type_(other.type_) {}

    // Assignment operator
    Item& Item::operator=(const Item& other) {
        if (this != &other) {
            name_ = other.name_;
            healthBoost_ = other.healthBoost_;
            attackBoost_ = other.attackBoost_;
            defenseBoost_ = other.defenseBoost_;
            type_ = other.type_;
        }
        return *this;
    }

    // Apply item effects to a character
    void Item::apply(ICharacter& character) const {
        // Directly modify the character's stats
        character.addItem(new Item(*this)); // Add a copy to inventory
    }

    // Getters
    std::string Item::getName() const { 
        return name_; 
    }

    int Item::getHealthBoost() const { 
        return healthBoost_; 
    }

    int Item::getAttackBoost() const { 
        return attackBoost_; 
    }

    int Item::getDefenseBoost() const { 
        return defenseBoost_; 
    }

    Item::Type Item::getType() const { 
        return type_; 
    }
}